package com.grass.p019lv.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.bean.InventionThreeBean;
import com.androidx.p013lv.base.bean.StarBean;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.p015ui.LazyFragment;
import com.androidx.p013lv.base.utils.NetUtil;
import com.grass.p019lv.adapter.AllActressAdapter;
import com.grass.p019lv.adapter.HotActressAdapter;
import com.grass.p019lv.databinding.FragmentPopularActreeBinding;
import com.youth.banner.Banner;

/* renamed from: com.grass.lv.fragment.PopularActressFragment */
public class PopularActressFragment extends LazyFragment<FragmentPopularActreeBinding> {
    String HTTP_TAG = "getFeaturedContentList";
    private AllActressAdapter allActressAdapter;
    View headerView;
    private HotActressAdapter hotActressAdapter;
    RecyclerView rv_top;
    int type;

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public int setFragmentView() {
        return R.layout.fragment_popular_actree;
    }

    public static PopularActressFragment newInstance(int i) {
        Bundle bundle = new Bundle();
        PopularActressFragment popularActressFragment = new PopularActressFragment();
        bundle.putSerializable("type", Integer.valueOf(i));
        popularActressFragment.setArguments(bundle);
        return popularActressFragment;
    }

    @Override // androidx.fragment.app.Fragment
    public void setArguments(Bundle bundle) {
        super.setArguments(bundle);
        this.type = bundle.getInt("type", 1);
    }

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public void initViews() {
        View inflate = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_popular_actress_header, (ViewGroup) null);
        this.headerView = inflate;
        Banner banner = (Banner) inflate.findViewById(R.id.banner);
        this.rv_top = (RecyclerView) this.headerView.findViewById(R.id.rv_top);
        ((TextView) this.headerView.findViewById(R.id.tv_all_title)).setText(this.type == 1 ? "全部女優" : "全部工作室");
        this.rv_top.setLayoutManager(new LinearLayoutManager(getActivity()));
        HotActressAdapter hotActressAdapter2 = new HotActressAdapter();
        this.hotActressAdapter = hotActressAdapter2;
        this.rv_top.setAdapter(hotActressAdapter2);
        ((FragmentPopularActreeBinding) this.binding).recycler.setLayoutManager(new GridLayoutManager(getActivity(), 4));
        AllActressAdapter allActressAdapter2 = new AllActressAdapter();
        this.allActressAdapter = allActressAdapter2;
        allActressAdapter2.addHeaderView(this.headerView);
        ((FragmentPopularActreeBinding) this.binding).recycler.setAdapter(this.allActressAdapter);
        ((FragmentPopularActreeBinding) this.binding).statusLayout.setOnRetryListener(new View.OnClickListener() {
            /* class com.grass.p019lv.fragment.PopularActressFragment.View$OnClickListenerC30041 */

            public void onClick(View view) {
                PopularActressFragment.this.getInfo();
            }
        });
        getInfo();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void getInfo() {
        if (!NetUtil.isNetworkAvailable()) {
            ((FragmentPopularActreeBinding) this.binding).statusLayout.showNoNet();
            return;
        }
        ((FragmentPopularActreeBinding) this.binding).statusLayout.showLoading();
        HttpUtils.getInsatance().get(UrlManager.getInsatance().getFeaturedContentList(this.type), new HttpCallback<BaseRes<StarBean>>(this.HTTP_TAG) {
            /* class com.grass.p019lv.fragment.PopularActressFragment.C30052 */

            public void onLvSuccess(BaseRes<StarBean> baseRes) {
                if (PopularActressFragment.this.binding != null && ((FragmentPopularActreeBinding) PopularActressFragment.this.binding).statusLayout != null && PopularActressFragment.this.getActivity() != null) {
                    ((FragmentPopularActreeBinding) PopularActressFragment.this.binding).statusLayout.hideLoading();
                    if (baseRes.getCode() == 200) {
                        PopularActressFragment.this.rv_top.setVisibility(0);
                        if (baseRes.getData() == null || baseRes.getData().getFeaturedList() == null || baseRes.getData().getFeaturedList().size() <= 0) {
                            baseRes.getData().getFeaturedList().clear();
                            baseRes.getData().getFeaturedList().add(new InventionThreeBean(true));
                            PopularActressFragment.this.rv_top.setVisibility(8);
                            PopularActressFragment.this.hotActressAdapter.setNewInstance(baseRes.getData().getFeaturedList());
                            PopularActressFragment.this.hotActressAdapter.notifyDataSetChanged();
                            PopularActressFragment.this.allActressAdapter.setNewInstance(baseRes.getData().getAllContentList());
                            PopularActressFragment.this.allActressAdapter.setDomain(baseRes.getData().getDomain());
                            PopularActressFragment.this.allActressAdapter.notifyDataSetChanged();
                            return;
                        }
                        PopularActressFragment.this.hotActressAdapter.setDomain(baseRes.getData().getDomain());
                        PopularActressFragment.this.hotActressAdapter.setNewInstance(baseRes.getData().getFeaturedList());
                        PopularActressFragment.this.allActressAdapter.setDomain(baseRes.getData().getDomain());
                        PopularActressFragment.this.allActressAdapter.setNewInstance(baseRes.getData().getAllContentList());
                        return;
                    }
                    ((FragmentPopularActreeBinding) PopularActressFragment.this.binding).statusLayout.showError();
                }
            }
        });
    }

    @Override // androidx.fragment.app.Fragment, com.gyf.immersionbar.components.ImmersionFragment
    public void onDestroy() {
        super.onDestroy();
        HttpUtils.getInsatance().cancelTag(this.HTTP_TAG);
    }
}
